package io.chain.ko.util;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;

@SuppressWarnings("unchecked")
public class CopyUtils {
	public static<T,K> List<K> copy(List<T> source,Class<?> clazz) {	
		List<K> targetList=new ArrayList<>();
		for(T t:source) {			
			try {
				K k = (K) clazz.newInstance();	
				targetList.add(k);
				BeanUtils.copyProperties(t,k);	
			} 
			catch (Exception e) {				
			}			
		}
		return targetList;
	}
}
